package com.JingYan.elasticSearch.service.impl;

import com.JingYan.domain.page.PageDomain;
import com.JingYan.elasticSearch.service.PdocDwApplicationdataRepository;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.JingYan.elasticSearch.domain.PdocDwApplicationdata;
import com.JingYan.elasticSearch.service.PdocDwApplicationdataService;
import com.JingYan.elasticSearch.mapper.PdocDwApplicationdataMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author DongJiaQi
* @description 针对表【pdoc_dw_applicationdata(文档的主内容)】的数据库操作Service实现
* @createDate 2022-12-15 14:16:37
*/
@Service
@Slf4j
public class PdocDwApplicationdataServiceImpl extends ServiceImpl<PdocDwApplicationdataMapper, PdocDwApplicationdata>
    implements PdocDwApplicationdataService{

    @Lazy
    @Autowired
    PdocDwApplicationdataServiceImpl self;

    @Autowired
    PdocDwApplicationdataRepository pdocDwApplicationdataRepository;
    @Override
    public void saveEs(){
        List<PdocDwApplicationdata> list = self.list();
        pdocDwApplicationdataRepository.saveAll(list);
        log.info("保存 pdocDwApplicationdata 文件信息完成");
    }
    @Override
    public List<PdocDwApplicationdata> listEs(PdocDwApplicationdata pdocDwApplicationdata, PageDomain pageDomain){
        PageRequest of = PageRequest.of(pageDomain.getPageNum(), pageDomain.getPageSize());
        return pdocDwApplicationdataRepository.findByFileName(pdocDwApplicationdata.getFileName(),of);
    }
}




